/* ladw.t ALLOCATION DETAIL BY LOCATION WRITE TRIGGER                 */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert*/
/*********************************************************************/
/*  Program :ladw.t                                                  */
/*  Author  :Ben Holmes                                              */
/*  Date    :03/19/95                                                */
/*  !Description : lad_det WRITE trigger program                     */
/*          : In order to enhance this trigger to support additional */
/*          : interfaces, add a DO-END block similar to the one      */
/*          : used for the Warehousing Interface to (1) check for the*/
/*          : need to continue processing; (2) move the relevant     */
/*          : fields to an appropriate work area; and (3) call       */
/*          : one or more subprograms to continue processing.        */
/*          : This .t program should remain short, relying on        */
/*          : subprograms to perform most of the work.               */
/*********************************************************************/
/*                             MODIFY LOG                            */
/*********************************************************************/
/*Revision 8.5          Last Modified:  03/19/96 BY: BHolmes *J0FY*  */
/*Revision 8.5          Last Modified:  07/19/96 BY: fwy     *J0MB*  */
/*Revision 8.5          Last Modified:  07/27/96 BY: fwy     *J12B*  */
/*Revision 8.5          Last Modified:  01/07/97 BY: jpm     *J1DM*  */
/*Revision 9.1          Last Modified:  09/07/99 BY: *N02J* Robert Jensen   */
/*Revision 9.1          Last Modified:  08/13/00 BY: *N0KR* myb             */
/*                                                                   */
/*                                                                   */
/*********************************************************************/

TRIGGER PROCEDURE FOR WRITE OF LAD_DET OLD BUFFER OLD_LAD_DET.

    {mfdeclre.i }

/*J12B  if not can-find(first whl_mstr where whl_mstr.whl_act no-lock) */
/*J12B  then leave. */

    define new shared work-table wf_old_lad_det like lad_det.
    define new shared variable w-recid as recid.
    define new shared variable w-site-loc-id like whl_mstr.whl_src_dest_id.
    define variable w-file as character format "x(24)".


    /* Warehousing Interface processing */

    WI:
    do:

    /* If there is no active external warehouse that is flagged to
    receive sales order, distribution order, work order, or
    repetitive picklist export transactions, then do not process */
/*J12B*/    if not can-find(first whl_mstr no-lock
/*J12B*/        where whl_mstr.whl_act
/*J12B*/          and (whl_mstr.whl_so_exp
/*J12B*/           or  whl_mstr.whl_do_exp
/*J12B*/           or  whl_mstr.whl_wo_exp
/*J12B*/           or  whl_mstr.whl_rps_exp))
/*J12B*/    then leave WI.

    /* If the lad_det record is not associated with a sales order,
    distribution order, work order, or repetitive picklist,
    then do not process */
/*J12B*/    if    lad_det.lad_dataset ne "wod_det"
/*J12B*/      and lad_det.lad_dataset ne "sod_det"
/*J12B*/      and lad_det.lad_dataset ne "ds_det"
/*J12B*/      and lad_det.lad_dataset ne "rps_det"
/*J12B*/    then leave WI.

    /* If there is no picked quantity on the lad_det,
    then do not process */
/*J0MB*/    if lad_det.lad_qty_pick lt 0 then leave WI.

    /* If the picked quantity on the lad_det has not changed,
    then do not process */
/*J0MB*/    if old_lad_det.lad_qty_pick = lad_det.lad_qty_pick then leave WI.

    /* Move old lad_det values to work table for subsequent processing */
        assign w-recid = recid(lad_det).
        create wf_old_lad_det.
        if recid(wf_old_lad_det)= -1 then.
        assign
/*J0MB*/        wf_old_lad_det.lad_dataset   = old_lad_det.lad_dataset
            wf_old_lad_det.lad_nbr       = old_lad_det.lad_nbr
            wf_old_lad_det.lad_line      = old_lad_det.lad_line
            wf_old_lad_det.lad_site      = old_lad_det.lad_site
            wf_old_lad_det.lad_loc       = old_lad_det.lad_loc
            wf_old_lad_det.lad_part      = old_lad_det.lad_part
/*J0MB          wf_old_lad_det.lad_lot       = old_lad_det.lad_lot */
/*J0MB          wf_old_lad_det.lad_ref       = old_lad_det.lad_ref */
            wf_old_lad_det.lad_qty_pick  = old_lad_det.lad_qty_pick
/*J0MB          wf_old_lad_det.lad_user1     = old_lad_det.lad_user1 */
/*J0MB          wf_old_lad_det.lad_user2     = old_lad_det.lad_user2 */
        .

    /* Call subprogram to create export transactions for warehouse */
        w-file = "wiladw.p".
/*J1DM*/ /* {gprun.i ""wiladw.p""} */
/*J1DM*/    {gprunmo.i &module="WI"
                       &program="wiladw.p"}

/*J12B*/end. /* WI */

/*N02J*//* Logistics Interface processing */
/*N02J*/LG:
/*N02J*/do:
/*N02J*/   if can-find (first lgs_mstr where lgs_app_id > "") then do:
/*N02J*/      if (lad_det.lad_dataset = "sod_det") then do:
/*N02J*/         if not can-find(first wf_old_lad_det) then do:
/*N02J*/            create wf_old_lad_det.
/*N02J*/            if recid(wf_old_lad_det)= -1 then .
/*N02J*/         end.
/*N02J*/         buffer-copy old_lad_det to wf_old_lad_det no-error.
/*N02J*//*       Call subprogram to publish changed status for Logistics */
/*N02J*/         {gprunmo.i &module="LG"
/*N02J*/         &program="lgladex.p"
/*N02J*/         &param="""(input recid(lad_det), input no)"""}
/*N02J*/      end. /* sod_det */
           end.
/*N02J*/end. /* LG */
/*N02J*//*End of Added Section */
